﻿@model ProductReviewsModel

@using SmartStore.Web.Models.Catalog;

@{
    Layout = "_Layout";

    Html.AddTitleParts(Model.ProductName.Value);
    Html.AddTitleParts(T("PageTitle.ProductReviews").Text);
}

<div class="page product-reviews-page">
    <div class="page-title">
        <h1 class="h3 d-flex align-items-baseline">
			<span class="pr-2">@T("Reviews.ProductReviewsFor")</span>
			<small @Html.LanguageAttributes(Model.ProductName)>
				<a href="@Url.RouteUrl("Product", new { SeName = Model.ProductSeName })" style="text-decoration: none;">@Model.ProductName</a>
			</small>	
		</h1>
    </div>

    <div class="page-body">
        @{ Html.RenderWidget("productreviews_page_top"); }

        @if(Model.SuccessfullyAdded && Model.Result.HasValue())
        {
            <div class="alert alert-success">
				<button type="button" class="close" data-dismiss="alert" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
                @Model.Result
            </div>
		}
		else
		{
			if (!ViewData.ModelState.IsValid)
			{
				@Html.ValidationSummary("", new { @class = "alert alert-danger m-b-0" })
			}
			<div class="write-review mb-4" id="review-form">
                <h4 class="d-none">@T("Reviews.Overview.AddNew")</h4>
                @using (Html.BeginForm())
				{
					@Html.AntiForgeryToken()
                    <div class="form-group row">
                        @Html.LabelFor(model => model.Rating, new { @class = "form-control-label col-form-label col-md-3" })
                        <div class="col-md-9 star-rating-parent">
                            <div class="review-rating star-rating star-rating-large">
                                @{
                                    var srName = Html.FieldNameFor(x => x.Rating);
                                }
                                <input type="radio" id="@(srName)5" name="@srName" value="5" checked="@(5 == Model.Rating)" /><label for="@(srName)5" class="tooltip-toggle" title="@T("Reviews.Fields.Rating.Excellent")"></label>
                                <input type="radio" id="@(srName)4" name="@srName" value="4" checked="@(4 == Model.Rating)" /><label for="@(srName)4"></label>
                                <input type="radio" id="@(srName)3" name="@srName" value="3" checked="@(3 == Model.Rating)" /><label for="@(srName)3"></label>
                                <input type="radio" id="@(srName)2" name="@srName" value="2" checked="@(2 == Model.Rating)" /><label for="@(srName)2"></label>
                                <input type="radio" id="@(srName)1" name="@srName" value="1" checked="@(1 == Model.Rating)" /><label for="@(srName)1" class="tooltip-toggle" title="@T("Reviews.Fields.Rating.Bad")"></label>
                            </div>
                        </div>
                    </div>
                    <div class="form-group row">
                        @Html.LabelFor(model => model.Title, new { @class = "form-control-label col-form-label col-md-3 required" })
						<div class="col-md-9">
							@Html.TextBoxFor(model => model.Title, Model.CanCurrentCustomerLeaveReview ? (object)(new { @class = "form-control" }) : (object)(new { @class = "form-control", disabled = "disabled" }))
							@Html.ValidationMessageFor(model => model.Title, null)
						</div>
                    </div>
                    <div class="form-group row">
                        @Html.LabelFor(model => model.ReviewText, new { @class = "form-control-label col-form-label col-md-3 required" })
						<div class="col-md-9">
							@Html.TextAreaFor(model => model.ReviewText, 4, 1, Model.CanCurrentCustomerLeaveReview ? (object)(new { @class = "form-control" }) : (object)(new { @class = "form-control", disabled = "disabled" }))
							@Html.ValidationMessageFor(model => model.ReviewText, null)
						</div>
                    </div>
                    
                    <div class="form-group">
                        <div class="col col-sm-auto offset-sm-3 text-muted">
                            @T("Common.FormFields.Required.Hint")
                        </div>
                    </div>

					<div class="row justify-content-end">
						<div class="col-sm-9">
							@{ Html.RenderWidget("gdpr_consent"); }
						</div>
					</div>

                    if (Model.DisplayCaptcha)
                    {
                        <div class="captcha-box form-group row justify-content-end">
							<div class="col-md-9">
								@Html.Raw(Html.GenerateCaptcha())
							</div>
                        </div>
                    }

                    <div class="form-group row m-b-0 justify-content-end">
						<div class="col-md-9">
							<button type="submit" name="add-review" value="add-review" class="btn btn-primary write-product-review-button">
								<span>@T("Reviews.SubmitButton")</span>
							</button>
						</div>
                    </div>
                }
            </div>
        }

        @if (Model.Items.Count > 0)
        {
            <div class="block">
                <div class="block-title">
                    <h3 class="d-flex align-items-center">
						<span>@T("Reviews.ExistingReviews")</span> 
						<small class="text-muted pl-2 lrm">(@Model.Items.Count)</small>
					</h3>
                </div>
                <div class="block-body pt-3">
					@{ Html.RenderPartial("Product.Reviews", Model); }
                </div>
            </div>
        }

        @{ Html.RenderWidget("productreviews_page_bottom"); }

    </div>
</div>
